<?php

include_once("core/controller.php");
include_once("core/libs/configFile.php");
include_once("core/versionHandler.php");
/**
 * This Controller is used to activate/desactivate maintenance state
 * @copyright inovia
 * @package oolime_manager
 *
 */
class SwitchMaintenance extends Controller {
   
	// only for manager group
	function isLegitimate(){
    return true;
	}

	function actions(){
		global $configMaintenance;
		$conf = new ConfigFile();

		/* Switch the maintenance state and create xml for maintenance */

		// switch the maintenance state to false
  	if((int) $configMaintenance == 1){
	    if($conf->setVar("\$configMaintenance","0",true)){
	     $configMaintenance = 0;
	    }else{
	      $this->response->addError('Maintenance state on','Maintenance');
	    }

		// switch the maintenance state to true
		}else{
      if($conf->setVar("\$configMaintenance","1",true)){
	     $configMaintenance = 1;
	    }else{
	      $this->response->addError('Maintenance state off','Maintenance');
	    }

		}

		/* Launch homeMaintenance*/
		include('controls/manager/homeMaintenance.php');
		$this->response->setXSLT('views/manager/homeMaintenance.xsl');
		new HomeMaintenance();
  }

	function defaultActions(){}
}



?>
